home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / com_net / mail / thor / thor.lha / rexx / UUEncode.thor < prev    next >
Encoding:
Text File  |  1994-08-06  |  3.2 KB  |  115 lines

  1. /* UUEncode.thor · by Troels Walsted Hansen
  2. ** $VER: UUEncode.thor v1.43 (19.03.94)
  3. **
  4. ** An ARexx script that uuencodes a file and either places it in the
  5. ** clipboard or posts a message for you containing the file. Using
  6. ** LhA, this script will archive the file if it isn't already.
  7. **
  8. ** Utilises uuIn by Nicolas Dade, MagicClip by Franz Schwarz
  9. ** and LhA by Stefan Boberg.
  10. **
  11. ** Known to be work with uuIn v1.03, MagicClip v1.2 and LhA 1.38.
  12. */
  13.  
  14. /* some user varibles. edit to your hearts content */
  15.  
  16. tmpdir = "T:"               /* Work dir for the encoding            */
  17.  
  18. /* this is where the action begins.. */
  19.  
  20. options results
  21.  
  22. if(substr(address(),1,4) ~= "THOR") then do
  23.     parse arg portname
  24.     if~(show(p, portname)) then do
  25.         if ~(show(p, "THOR.01")) then do
  26.             say "No THOR port found!"
  27.             exit
  28.         end
  29.         else portname = "THOR.01"
  30.     end
  31. end
  32. else portname = address()
  33.  
  34. address(portname)
  35.  
  36. if ~show(l, 'rexxsupport.library') then do
  37.     if ~addlib('rexxsupport.library', 0, -30) then do
  38.         say "Please install rexxsupport.library in your libs: directory"
  39.         exit
  40.     end
  41. end
  42.  
  43. /* main stuff */
  44.  
  45. GETGLOBALCONFIG
  46. THORTOFRONT
  47. REQUESTFILE TITLE '"Select file to encode:"' ID '"'GLOBALCONFIG.UPLOADPATH'"' FP PAT '"#?"'
  48.  
  49. filetoencode = result
  50. lastchar = right(filetoencode,1)
  51.  
  52. if(rc~=0|lastchar = "/"|lastchar = ":"|filetoencode = "") then do
  53.     REQUESTNOTIFY TEXT '"No file selected!"' BT '"_Ok"'
  54.     call CleanUp()
  55. end
  56.  
  57. posi = lastpos("/",FileToEncode)
  58. if(posi = 0) then posi = lastpos(":",FileToEncode)
  59. WithoutPath = substr(FileToEncode,posi+1)
  60.  
  61. /* if file isn't LhA'ed -- do it ourselves */
  62.  
  63. extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
  64.  
  65. if~(extension = "LHA" | extension = "LZH") then do
  66.     REQUESTNOTIFY TEXT '"Do you want to LhA the file?"' BT '"_Yes|_No"'
  67.     if(result) then do
  68.         address command "LhA -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
  69.         FileToEncode = tmpdir||WithoutPath||".lha"
  70.     end
  71. end
  72.  
  73. address command "uuIn INFILE="||'"'filetoencode'"'||" OUTFILE="||tmpdir||"Message.uu"
  74.  
  75. if ~exists(tmpdir"Message.uu") then do
  76.     REQUESTNOTIFY TEXT '"File containing uuencoded data not found."' BT '"_Ok"'
  77.     call CleanUp()
  78. end
  79.  
  80. REQUESTNOTIFY TEXT '"Place in clipboard or post as a message?"' BT '"Clip_board|_Post|_Cancel"'
  81. choice = result
  82.  
  83. if(choice = 1) then address command "MagicClip >nil: FILE="tmpdir"Message.uu"
  84. else if(choice = 2) then do
  85.     REQUESTLIST BBSLIST
  86.     bbsname = result
  87.     if(rc ~= 0|bbsname = "") then break
  88.  
  89.     REQUESTLIST CONFLIST BBS '"'bbsname'"'
  90.     confname = result
  91.     if(rc ~= 0) then break
  92.  
  93.     REQUESTSTRING TITLE '"Please enter subject of message:"' BT '"_Ok|_Cancel"' ID WithoutPath MAXCHARS 100
  94.     subject = result
  95.     if(rc ~= 0|subject = "") then break
  96.  
  97.     REQUESTSTRING TITLE '"Please enter receiver name:"' BT '"_Ok|_Cancel"' ID '"ALL"' MAXCHARS 100
  98.     receiver = result
  99.     if(rc ~= 0|receiver = "") then break
  100.  
  101.     ADDEVENT BBS '"'bbsname'"' EVENT ENTERMSG SENDTO '"'receiver'"' CONF '"'confname'"' MSGFILE tmpdir"Message.uu" SUB '"'subject'"'
  102.     if(rc ~= 0) then REQUESTNOTIFY TEXT '"Failed to post message!"' BT '"_Ok"'
  103.     else PACKEVENTS '"'bbsname'"'
  104. end
  105.  
  106. call CleanUp()
  107.  
  108. /* cleanup and exit */
  109.  
  110. CleanUp:
  111.     if(exists(tmpdir||WithoutPath||".lha")) then call delete(tmpdir||WithoutPath||".lha")
  112.     if(exists(tmpdir||"Message.uu")) then call delete(tmpdir"Message.uu")
  113.     exit
  114. return
  115.